package com.demo.house;

import com.demo.common.model.House;
import com.demo.common.model.User;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class HouseValidator extends Validator {

    protected void validate(Controller controller) {
        validateRequiredString("house.housename", "housenameMsg", "请输入楼盘名字!");
        validateRequiredString("house.houselocation", "houselocationMsg", "请输入楼盘位置!");
        validateRequiredString("house.price", "priceMsg", "请输入租赁价格!");
    }

    protected void handleError(Controller controller) {
        controller.keepModel(House.class);

        String actionKey = getActionKey();
        if (actionKey.equals("/house/save"))
            controller.render("add.html");
        else if (actionKey.equals("/house/update"))
            controller.render("edit.html");
    }
}
